package com.miszczu.model;
// Generated 2012-03-05 20:16:25 by Hibernate Tools 3.4.0.CR1


import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

/**
 * Users generated by hbm2java
 */
@Entity
@Table(name="users"
    ,catalog="dziennik"
    , uniqueConstraints = @UniqueConstraint(columnNames="user_login") 
)
public class Users  implements java.io.Serializable {

	@Transient
	private Double average;
	
	 public Double getAverage() {
		return average;
	}


	public void setAverage(Double average) {
		this.average = average;
	}

	@Transient
	 private String repeatPassword;
     public String getRepeatPassword() {
		return repeatPassword;
	}


	public void setRepeatPassword(String repeatPassword) {
		this.repeatPassword = repeatPassword;
	}

	private Integer userId;
     private Accounttypes accounttypes;
     private String userLogin;
     private String userPassword;
     private String firstName;
     private String lastName;
     
     @Column(name="first_name", unique=false, nullable=false, length=100)
     public String getFirstName() {
		return firstName;
	}

    
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@Column(name="last_name", unique=false, nullable=false, length=100)
	public String getLastName() {
		return lastName;
	}


	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	 @Transient
	 private String classMember;
	 public String getClassMember() {
		return classMember;
	}


	public void setClassMember(String classMember) {
		this.classMember = classMember;
	}

	private String salt;
     private String email;
     private Set<Messagesreceived> messagesreceiveds = new HashSet<Messagesreceived>(0);
     private Set<Grades> gradeses = new HashSet<Grades>(0);
     private Set<Classes> classeses = new HashSet<Classes>(0);
     private Set<Messages> messagesesForToUser = new HashSet<Messages>(0);
     private Set<Messages> messagesesForFrom = new HashSet<Messages>(0);

    public Users() {
    }

	
    public Users(Accounttypes accounttypes, String userLogin, String userPassword, String salt) {
        this.accounttypes = accounttypes;
        this.userLogin = userLogin;
        this.userPassword = userPassword;
        this.salt = salt;
    }
    public Users(Accounttypes accounttypes, String userLogin, String userPassword, String firstName, String lastName, String salt, String email, Set<Messagesreceived> messagesreceiveds, Set<Grades> gradeses, Set<Classes> classeses, Set<Messages> messagesesForToUser, Set<Messages> messagesesForFrom) {
       this.accounttypes = accounttypes;
       this.userLogin = userLogin;
       this.userPassword = userPassword;
       this.firstName = firstName;
       this.lastName = lastName;
       this.salt = salt;
       this.email = email;
       this.messagesreceiveds = messagesreceiveds;
       this.gradeses = gradeses;
       this.classeses = classeses;
       this.messagesesForToUser = messagesesForToUser;
       this.messagesesForFrom = messagesesForFrom;
    }
   
     @Id @GeneratedValue(strategy=IDENTITY)

    
    @Column(name="user_id", unique=true, nullable=false)
    public Integer getUserId() {
        return this.userId;
    }
    
    public void setUserId(Integer userId) {
        this.userId = userId;
    }

@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="account_type_id", nullable=false)
    public Accounttypes getAccounttypes() {
        return this.accounttypes;
    }
    
    public void setAccounttypes(Accounttypes accounttypes) {
        this.accounttypes = accounttypes;
    }

    
    @Column(name="user_login", unique=true, nullable=false, length=45)
    public String getUserLogin() {
        return this.userLogin;
    }
    
    public void setUserLogin(String userLogin) {
        this.userLogin = userLogin;
    }

    
    @Column(name="user_password", nullable=false, length=32)
    public String getUserPassword() {
        return this.userPassword;
    }
    
    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    
    @Column(name="salt", nullable=false, length=32)
    public String getSalt() {
        return this.salt;
    }
    
    public void setSalt(String salt) {
        this.salt = salt;
    }

    
    @Column(name="email", length=100)
    public String getEmail() {
        return this.email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }

@OneToMany(fetch=FetchType.LAZY, mappedBy="users")
    public Set<Messagesreceived> getMessagesreceiveds() {
        return this.messagesreceiveds;
    }
    
    public void setMessagesreceiveds(Set<Messagesreceived> messagesreceiveds) {
        this.messagesreceiveds = messagesreceiveds;
    }

@OneToMany(fetch=FetchType.LAZY, mappedBy="users")
    public Set<Grades> getGradeses() {
        return this.gradeses;
    }
    
    public void setGradeses(Set<Grades> gradeses) {
        this.gradeses = gradeses;
    }

@ManyToMany(fetch=FetchType.EAGER)
    @JoinTable(name="usersclasses", catalog="dziennik", joinColumns = { 
        @JoinColumn(name="user_id", nullable=false, updatable=false) }, inverseJoinColumns = { 
        @JoinColumn(name="class_id", nullable=false, updatable=false) })
    public Set<Classes> getClasseses() {
        return this.classeses;
    }
    
    public void setClasseses(Set<Classes> classeses) {
        this.classeses = classeses;
    }

@OneToMany(fetch=FetchType.LAZY, mappedBy="usersByToUser")
    public Set<Messages> getMessagesesForToUser() {
        return this.messagesesForToUser;
    }
    
    public void setMessagesesForToUser(Set<Messages> messagesesForToUser) {
        this.messagesesForToUser = messagesesForToUser;
    }

@OneToMany(fetch=FetchType.LAZY, mappedBy="usersByFrom")
    public Set<Messages> getMessagesesForFrom() {
        return this.messagesesForFrom;
    }
    
    public void setMessagesesForFrom(Set<Messages> messagesesForFrom) {
        this.messagesesForFrom = messagesesForFrom;
    }




}


